<?php
	require_once("action/dao/Connection.php");

	class ResearchDAO {
	
		public static function recherche($nompage,$language)
		{
			$connection = Connection::connect();
			
			if($nompage=="ACCUEIL")
			{
				$query = "SELECT TITRE,TEXTE,ID FROM B63_PAGESINFOS WHERE NOMPAGE=:pnompage AND LANGUE=:planguage";				
				$statement = oci_parse($connection, $query);
				oci_bind_by_name($statement, ":pnompage", $nompage);
				oci_bind_by_name($statement, ":planguage", $language);
			}
			else if($nompage=="COMPAGNIE")
			{
				$query = "SELECT TITRE,TEXTE FROM B63_PAGESINFOS WHERE NOMPAGE=:pnompage AND LANGUE=:planguage";				
				$statement = oci_parse($connection, $query);
				oci_bind_by_name($statement, ":pnompage", $nompage);
				oci_bind_by_name($statement, ":planguage", $language);
			}
			else if($nompage=="HISTORIQUE")
			{
				$query = "SELECT TITRE,TEXTE FROM B63_PAGESINFOS WHERE NOMPAGE=:pnompage AND LANGUE=:planguage";				
				$statement = oci_parse($connection, $query);
				oci_bind_by_name($statement, ":pnompage", $nompage);
				oci_bind_by_name($statement, ":planguage", $language);
			}
			else if($nompage=="EQUIPE")
			{
				$query = "SELECT NOM,FONCTION,DESCRIPTION,LIENPHOTO,ID FROM B63_EQUIPE WHERE LANGUE=:planguage";				
				$statement = oci_parse($connection, $query);
				oci_bind_by_name($statement, ":planguage", $language);
			}
			else if($nompage=="PHOTOS")
			{
				$query = "SELECT DESCRIPTION,LIENPHOTO FROM B63_GALERIEPHOTOS WHERE LANGUE=:planguage";				
				$statement = oci_parse($connection, $query);
				oci_bind_by_name($statement, ":planguage", $language);
			}
			else if($nompage=="CARRIERES")
			{
				$query = "SELECT EMPLOI, CONDITIONS, ID FROM B63_CARRIERES WHERE LANGUE=:planguage";
				$statement = oci_parse($connection, $query);
				oci_bind_by_name($statement, ":planguage", $language);
			}
			else if($nompage=="SERVICES")
			{
				$query = "SELECT NOM, DESCRIPTION, ID FROM B63_SERVICES WHERE LANGUE=:planguage";
				$statement = oci_parse($connection, $query);
				oci_bind_by_name($statement, ":planguage", $language);
			}
			else if($nompage=="CONTACTEZ")
			{
				$query = "SELECT ADRESSE, LIENCARTE FROM B63_CONTACTS";
				$statement = oci_parse($connection, $query);
			}			
				
			oci_execute($statement);
			
			while ($row = oci_fetch_array($statement))
			{
				$reponse[]=$row;
			}			
						
			Connection::close($connection);
			
			return $reponse;			
		}
		
		public function update($nompage,$editordata)
		{
			$connection = Connection::connect();
			
			$query = "UPDATE B63_PAGESINFOS SET TEXTE = :peditordata WHERE NOMPAGE=:pnompage AND LANGUE='FR'";
			
			$statement = oci_parse($connection, $query);
			
			oci_bind_by_name($statement, ":peditordata", $editordata);
			oci_bind_by_name($statement, ":pnompage", $nompage);
				
			oci_execute($statement);			
			
			Connection::close($connection);			
		}
		
		
	}
